package com.contract.spirit.manage

import android.annotation.SuppressLint
import android.content.Context
import android.view.Gravity
import android.widget.CheckBox
import android.widget.LinearLayout
import com.contract.commonlib.util.DisplayUtils
import com.contract.spirit.R

/**
 * @author: witness
 * created: 2021/9/30
 * desc:
 */
object CheckBoxManager {
    fun getCheckBox(mContext: Context, tag: String?): CheckBox? {
        val m5: Int = DisplayUtils.dip2px(20f)
        val top: Int = DisplayUtils.dip2px(3f)
        val ckb = CheckBox(mContext)
        ckb.setBackgroundResource(R.drawable.bg_checkbox_blue_label_selector)
        ckb.setButtonDrawable(R.drawable.bg_grey_border)
        @SuppressLint("UseCompatLoadingForColorStateLists") val csl =
            mContext.resources.getColorStateList(R.color.text_color_white_blue_selector)
        ckb.setTextColor(csl)
        ckb.setPadding(DisplayUtils.dip2px(10f), top, DisplayUtils.dip2px(10f), top)
        ckb.gravity = Gravity.CENTER
        val params = LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT
        )
        params.rightMargin = m5
        params.topMargin = DisplayUtils.dip2px(10f)
        ckb.layoutParams = params
        ckb.textSize = 14f
        ckb.text = tag
        return ckb
    }
}